Rework and enable Wasm.Build.Tests.Blazor.AssetCachingTests#123388
Rework and enable Wasm.Build.Tests.Blazor.AssetCachingTests#123388
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the Wasm.Build.Tests.Blazor.AssetCachingTests to improve test reliability by replacing stdout-based log parsing with an HTTP API endpoint. The test server now exposes /request-logs endpoints to retrieve and clear captured request logs, eliminating the previous source of flakiness.
Changes:
- Added request logging middleware and API endpoints to the BlazorWebWasm test server
- Created a client library (
BlazorWebWasmLogClient) to interact with the logging API from tests - Updated the test to use the new API-based approach instead of parsing server stdout
- Updated target framework from net10.0 to net11.0 in test assets
- Optimized Counter.razor to log only on first render
- Re-enabled the test by removing the ActiveIssue attribute and adding it back to BuildWasmAppsJobsList.txt
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| BlazorWebWasm/Program.cs | Added middleware to capture HTTP request logs and API endpoints to retrieve/clear logs |
| BlazorWebWasmRequestLog.cs (testasset) | New record type for capturing request details in the test server |
| BlazorWebWasm.csproj | Updated target framework from net10.0 to net11.0 |
| BlazorWebWasm.Client.csproj | Updated target framework from net10.0 to net11.0 |
| Counter.razor | Modified to log only on first render to reduce noise |
| ServerRequestLog.cs | New record type (appears unused) |
| BlazorWebWasmRequestLog.cs (test) | New record type matching the testasset structure for deserialization |
| BlazorWebWasmLogClient.cs | New HTTP client for interacting with the test server's logging API |
| AssetCachingTests.cs | Refactored to use the new API-based logging approach, removed ActiveIssue attribute |
| BuildWasmAppsJobsList.txt | Re-enabled AssetCachingTests in the test job list |
src/mono/wasm/testassets/BlazorWebWasm/BlazorWebWasm/Program.cs
Outdated
Show resolved
Hide resolved
src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWebWasmLogClient.cs
Outdated
Show resolved
Hide resolved
src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWebWasmLogClient.cs
Outdated
Show resolved
Hide resolved
src/mono/wasm/testassets/BlazorWebWasm/BlazorWebWasm/Program.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@oroztocil I've opened a new pull request, #123390, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@oroztocil I've opened a new pull request, #123392, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@oroztocil I've opened a new pull request, #123393, to work on those changes. Once the pull request is ready, I'll request review from you. |
src/mono/wasm/testassets/BlazorWebWasm/BlazorWebWasm/Program.cs
Outdated
Show resolved
Hide resolved
|
Tagging subscribers to this area: @akoeplinger, @matouskozak, @simonrozsival |
src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWebWasmLogClient.cs
Outdated
Show resolved
Hide resolved
|
@oroztocil I've opened a new pull request, #123430, to work on those changes. Once the pull request is ready, I'll request review from you. |
src/mono/wasm/testassets/BlazorWebWasm/BlazorWebWasm/BlazorWebWasm.csproj
Show resolved
Hide resolved
src/mono/wasm/testassets/BlazorWebWasm/BlazorWebWasm.Client/BlazorWebWasm.Client.csproj
Show resolved
Hide resolved
|
/backport to release/10.0 |
|
Started backporting to |
AssetCachingTestscheck that only the expected requests for Wasm assets are actually sent by the client to the server, based on whether asset fingerprinting is enabled or not. Fingerprinted assets should be always retrieved from the browser cache after the initial load.Previously, the test relied on reading server logs from the stdout of the test server application. This was likely the cause of the test's flakiness.
The PR replaces the mechanism with an API endpoint exposed by the the server that is used by the test code to retrieve the captured request logs. The test is re-enabled and added to
BuildWasmAppsJobsList.txt.